home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / src / p8pixblk.c < prev    next >
Text File  |  1993-12-06  |  3KB  |  98 lines

  1. /**
  2.  ** P8PIXBLK.C
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include "p8.h"
  25. #include "memfill.h"
  26.  
  27. void _GrP8SetPixBlock(long addr,int color,int w,int h)
  28. {
  29.     int oper = C_OPER(color);
  30.     int skip,w2;
  31.     pixptr p;
  32.  
  33.     if((w <= 0) || (h <= 0)) return;
  34.     if((_GrP8DrawTable[oper] ^ (color &= C_SIGNIF)) == 0) return;
  35.     _ClrDir();
  36.     if(CURC->gc_onscreen && _GrP8UsePlanarMode) {
  37.         if((oper == C_SET) && (w >= 12)) {
  38.         int rmask = ((int)addr + w) & 3;
  39.         int lmask = (int)addr & 3;
  40.         int offs = CURC->gc_lineoffset >> 2;
  41.  
  42.         PLANAR_MODE_ON();
  43.         p = P_XADDRESS(CURC,addr);
  44.         if(lmask) {
  45.             _SetVGAPlaneMask(_GrP8LmaskTable[lmask]);
  46.             _ColSetB(FASTLEFT,p,offs,color,h);
  47.             w -= (4 - lmask);
  48.             p++;
  49.         }
  50.         skip = offs - (w >>= 2);
  51.         _SetVGAPlaneMask(0xff);
  52.         if((offs & 1) || (w <= 4)) {
  53.             _BlkSetB(FASTBLKB,p,skip,color,w,h);
  54.             p += w;
  55.         }
  56.         else {
  57.             color |= (color << 8);
  58.             if((int)p & 1) {
  59.             _ColSetB(FASTBLKL,p,offs,color,h);
  60.             p++;
  61.             w--;
  62.             }
  63.             w2 = w >> 1;
  64.             skip = offs - (w2 << 1);
  65.             _BlkSetW(FASTBLKW,p,skip,color,w2,h);
  66.             p += (w2 << 1);
  67.             if(w & 1) {
  68.             _ColSetB(FASTBLKR,p,offs,color,h);
  69.             p++;
  70.             }
  71.         }
  72.         if(rmask) {
  73.             _SetVGAPlaneMask(_GrP8RmaskTable[rmask]);
  74.             _ColSetB(FASTRIGHT,p,offs,color,h);
  75.         }
  76.         return;
  77.         }
  78.         PLANAR_MODE_OFF();
  79.     }
  80.     p = P_ADDRESS(CURC,addr);
  81.     skip = CURC->gc_lineoffset - w;
  82.     if(((int)addr | skip | w) & 1) switch(oper) {
  83.         case C_XOR: _BlkSetXorB(XB,p,skip,color,w,h); return;
  84.         case C_OR:  _BlkSetOrB(OB,p,skip,color,w,h);  return;
  85.         case C_AND: _BlkSetAndB(AB,p,skip,color,w,h); return;
  86.         default:    _BlkSetB(WB,p,skip,color,w,h);      return;
  87.     }
  88.     w >>= 1;
  89.     color |= (color << 8);
  90.     switch(oper) {
  91.         case C_XOR: _BlkSetXorW(XW,p,skip,color,w,h); return;
  92.         case C_OR:  _BlkSetOrW(OW,p,skip,color,w,h);  return;
  93.         case C_AND: _BlkSetAndW(AW,p,skip,color,w,h); return;
  94.         default:    _BlkSetW(WW,p,skip,color,w,h);      return;
  95.     }
  96. }
  97.  
  98.